<?php

class JabatanDao {
    public function getJabatan($nip){
        $db= Database::getInstance();
        $con=$db->getConnection(2);

        $query="SELECT nip,jabatan FROM dt_jabatan WHERE nip='$nip' ORDER BY dateStart DESC LIMIT 1";
        $result=$con->prepare($query);
        $result->execute();

        if($result->rowCount()==1){
            $hasil=$result->fetch();
            return $hasil['jabatan'];
        }

        return false;
    }
}

class Jabatan {
    var $nip;
    var $jabatan;

}
//SELECT a.nip,a.nama,a.gol, a.unit,b.`jabatan`,b.`dateStart` FROM dt_emp a LEFT JOIN (SELECT nip,jabatan,dateStart FROM dt_jabatan) b ON a.nip=b.nip WHERE a.`active`='y' AND SUBSTR(a.unit,1,11)='11211015050'
//SELECT *,MAX(c.dateStart) FROM (SELECT nip,nama,gol,dateStart,jabatan FROM a ORDER BY nip,dateStart DESC) c LEFT JOIN t_gol d ON c.gol=d.kdgol GROUP BY nip

?>